﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThangNM_LIB.EO;
using ThangNM_LIB.FUNC;

namespace CSharp.UserControl
{
    public partial class PreviewUC : System.Web.UI.UserControl
    {
        #region "Properties & Event"
        protected KeyValueDataGroupEO objKVDG
        {
            get { return (KeyValueDataGroupEO)ViewState["objKVDG"]; }
            set { ViewState["objKVDG"] = value; }
        }

        protected Int16 iTypeTemp
        {
            get { return (Int16)ViewState["iTypeTemp"]; }
            set { ViewState["iTypeTemp"] = value; }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                MsgUC1.setClearMsg();
                if (!IsPostBack)
                {
                    if (Session["objKVDG"] != null)
                        objKVDG = (KeyValueDataGroupEO)Session["objKVDG"];
                    Session["objKVDG"] = null;
                    if (!String.IsNullOrEmpty(Request.QueryString["tt"]))
                        iTypeTemp = Convert.ToInt16(Request.QueryString["tt"]);
                    setView(iTypeTemp);
                }
            }
            catch (Exception ex)
            {
                MsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());
            }
        }

        protected void setView(Int16 iTypeReport)
        {
            String sContent = "";
            switch (iTypeReport)
            {
                case ConstEx.TypeReport.DEFAULT:
                    if (objKVDG != null)
                        sContent = objKVDG.D;
                    break;
                case ConstEx.TypeReport.ACCOUNT:
                    break;
                case ConstEx.TypeReport.ORDER:
                    if (objKVDG != null)
                        sContent = objKVDG.D;
                    break;
                default:
                    break;
            }
            BindData(sContent);
        }

        protected void BindData(String sTemp)
        {
            try
            {
                lblContent.Text = sTemp;
                MsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, MessagesEx.Khong_Thoa_Man_Dieu_Kien_Tim_Kiem, null);
            }
            catch (Exception ex)
            {
                MsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());
            }
        }
    }
}